package com.brsya.movie.ksAd;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.brsya.movie.R;


/**
 * KsContentPage 使用Fragment展示滑滑流
 */
public class TestContentPageFragmentActivity extends TestBaseActivity {
  private long mPosId;
  private TestBaseFragment mFragment;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppImmersiveUtils.startImmersiveMode(this, Color.TRANSPARENT, isDarkImmersiveMode());
    handleIntent();
    show();
  }

  @Override
  protected int getLayoutId() {
    return R.layout.activity_test_single_fragment;
  }

  @Override
  public void onBackPressed() {
    if (mFragment != null && mFragment.onBackPressed()) {
      return;
    }
    super.onBackPressed();
  }

  private void handleIntent() {
    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
      return;
    }
    mPosId = bundle.getLong(TestContentPageFragment.KEY_POS_ID);
  }

  public void show() {
    mFragment = TestContentPageFragment.newInstance(mPosId);
    getSupportFragmentManager().beginTransaction()
        .replace(R.id.test_fragment_container, mFragment)
        .commitAllowingStateLoss();
  }
}
